package com.runmi.webchat.aftersale.web.common.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.runmi.webchat.aftersale.common.result.Result;
import com.runmi.webchat.aftersale.common.result.ResultFactory;
import com.runmi.webchat.aftersale.dbcore.entity.RegionInfo;
import com.runmi.webchat.aftersale.dbcore.mapper.RegionInfoMapper;
import com.runmi.webchat.aftersale.web.base.BaseService;

import java.util.List;

/**
 * 区域服务接口
 * Created by zhusheng on 2017/11/17 0017.
 */
@Service
public class RegionService extends BaseService {
    @Autowired
    private RegionInfoMapper regionInfoMapper;

    /**
     * 根据父级区域id查询下一级子区域（市，县）列表信息，查询省级区域传0
     * @return
     */
    public Result queryRegionsByParentId(Integer parentRegionId) {
        Result result = ResultFactory.getResultFail();
        try {
             RegionInfo scmRegionInfo = new RegionInfo();
            scmRegionInfo.setParentId(parentRegionId);
            List<RegionInfo> scmRegionInfoList = regionInfoMapper.select(scmRegionInfo);
            result = ResultFactory.getResultSuccess(scmRegionInfoList);
        } catch (Exception e) {
            logErr.error("查询省级区域列表异常",e);
        }
        return result;
    }
}
